// pages/order/order.js
//引入js文件
var myOrder = require("../../data/order.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderNavtab: 0,
    order_list: [], //订单列表
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      order_list: myOrder.order_list.data,
    });
  },

  //切换tab
  switchTab: function (e) {
    var that = this;
    that.setData({
      orderNavtab: e.currentTarget.dataset.navid
    });
  },

  //详情
  detail: function (e) {

  },

  //翻页
  lowerMore: function (e) {
    console.log("lowerMore");
    wx.showNavigationBarLoading();
    var that = this;
    setTimeout(function () {
      wx.hideNavigationBarLoading();
      that.nextLoad();
    }, 1000);
  },

  //下一页
  nextLoad: function (e) {
    var that = this;
    wx.showToast({
      title: '加载中',
      icon: 'loading',
      duration: 4000
    })
    var next = myOrder.order_list;
    console.log("continueload");
    var next_data = next.data;
    console.log(next_data);
    that.setData({
      order_list: that.data.order_list.concat(next_data)
    });
    setTimeout(function () {
      wx.showToast({
        title: '加载成功',
        icon: 'success',
        duration: 2000
      })
    }, 3000);
  },

  //详情
  detail: function (e) {
    var id = e.currentTarget.dataset.key;
    console.log(id);
    wx.navigateTo({
      url: '../orderinfo/orderinfo?orderid=' + id,
    })
  },
})